// app.ts
import './utils/util'
App<IAppOption>({
  globalData: {
    token:"",
    userInfo:"",
    schoolList:[],
    memberList:[],
  },
  onLaunch() {
  this.getToken()
  },
  setUserType(type:string){
  return wx.setStorageSync("userType",type)
  },
  getUserType(){
  return wx.getStorageSync("userType")
  },
  // 获取token
  getToken(){
   return wx.getStorageSync("token") ?? ""
  },
  setToken(key:string,token:string){
    this.globalData.token = token
   wx.setStorageSync(key,token)
  },
  removeToken(key:string){
    wx.removeStorageSync(key)
  },
  // 获取用户信息
  getUserInfo(){
    if(typeof (wx.getStorageSync("userInfo")) === 'object'){
      return wx.getStorageSync("userInfo") ? wx.getStorageSync("userInfo")  :{}
    }
   },
  //  设置用户信息
  setUserInfo(key:string,userInfo:any){
    this.globalData.userInfo = userInfo
    wx.setStorageSync(key,userInfo)
  },
  // 删除用户信息
  removeUserInfo(key:string){
    wx.removeStorageSync(key)
  },
  //  获取校区列表
getSchoolList(){
  return wx.getStorageSync("schoolList") ?? {}
},
//设置校区列表
setSchoolList(list:Array<any>){
  this.globalData.schoolList = list
  wx.setStorageSync('schoolList',list)
},
  //  获取成员列表
  getMemberList(){
    return wx.getStorageSync("memberList") ?? {}
  },
  //设置成员列表
  setMemberList(list:Array<any>){
    this.globalData.memberList = list
    wx.setStorageSync('memberList',list)
  },
  //用户类型id
})